<!DOCTYPE html>
<html style="font-size: 100px;">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>选择位置</title>
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="css/ydui.css?v=1" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="css/all.css"/>
    <script src="js/ydui.flexible.js"></script>
    <style type="text/css">
    #l-map{height:6rem;width:100%;}
		#r-result{width:100%;}
	.anchorBL img{
		display: none;
	}
    </style>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=zbkmMQ0X6j701j2RDX89UIpd5RS9BfaT"></script>
</head>
<body style="background: #FFFFFF;" ms-controller="ditu">
    <div class="g-flexview">
        <div class="m-navbar">
            <a onclick="history.go(-1)" class="navbar-item">
                <i class="iconfont icon-back"></i>
            </a>
            <div class="navbar-center">
                <span class="navbar-title">地址选择</span>
            </div>
        </div>
        <div class="g-scrollview">
        	<div class="l-find">
        		<div class="content-input">
        			<form action="adresselect.html">      				
						<input type="search" ms-duplex="@find" ms-on-focus="@onfocus" placeholder="请输入搜索内容" name="key" id="" value="" />
        			</form>
        			
        		</div>
        		
        	</div>
			<div id="l-map"></div>
			<div id="r-result">
				<div class="adresslist-content clearfix" ms-for="el in @adress">
					<p class="adress-ico iconfont icon-dibiao"></p>
					<div class="content-text">
						<p class="title">{{el.split(',')[0]}}</p>
						<p class="content">{{el.split(',')[1]}}</p>
					</div>
					<a href="" class="sure-btn">确认选点</a>
				</div>
			</div>
        </div>
           





           


     </div>



    <script src="https://cdn.bootcss.com/jquery/2.2.0/jquery.min.js"></script>
    <script src="js/ydui.js"></script>
    <script src="js/avalon.mobile.min.js"></script>
    <script src="js/ComFunJS.js?v=20170929"></script>
	<script type="text/javascript">
	var model=avalon.define({
		$id:"ditu",
		xzuo:"",
		yzuo:"",
		find:ComFunJS.getQueryString('key'),
		adress:[],
		onfocus:function(){
			model.adress=[]
		}
	})
	avalon.ready(function(){
		var geolocation = new BMap.Geolocation();
		geolocation.getCurrentPosition(function(r){
			if(this.getStatus() == BMAP_STATUS_SUCCESS){
				var mk = new BMap.Marker(r.point);
				map.addOverlay(mk);
				map.panTo(r.point);
				model.xzuo=r.point.lng;
				model.yzuo=r.point.lat
				var point = new BMap.Point(model.xzuo,model.yzuo);
				map.centerAndZoom(point,12);
			}      
		},{enableHighAccuracy: true})	
		local.search(model.find);
	})
	// 百度地图API功能
	var map = new BMap.Map("l-map");		
	var options = {
		onSearchComplete: function(results){
			// 判断状态是否正确
			if (local.getStatus() == BMAP_STATUS_SUCCESS){
				for (var i = 0; i < results.getCurrentNumPois(); i ++){
					model.adress.push(results.getPoi(i).title + "," + results.getPoi(i).address);
				}
			}
		}
	};

	map.enableScrollWheelZoom(true);	
	var local = new BMap.LocalSearch(map, options);
	
	</script>
</body>
</html>
